package com.example.administrator.viewpagerdemo.hvandvv;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.administrator.viewpagerdemo.R;

import java.util.ArrayList;
import java.util.List;

public class DirectionalViewpagerActivity extends AppCompatActivity {
    private VerticalViewPager pager;
    private List<Fragment> lists;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_directional_viewpager);
        pager = (VerticalViewPager) findViewById(R.id.pager);
        lists = new ArrayList<>();
        lists.add(new TestFragment());
        lists.add(new TestFragment());
        pager.setAdapter(new MyAdapter(getSupportFragmentManager()));
    }

    private class MyAdapter extends FragmentPagerAdapter {

        public MyAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return lists.get(position);
        }

        @Override
        public int getCount() {
            return lists.size();
        }
    }
}
